﻿@model BusinessManagementStudio.ViewModel.CompanyOrder
@using System.Globalization;

@{
    ViewBag.Title = "Create New Order";
    TempData.Keep();
}

<title>JLL PO Creation</title>

<h2 align="center">Create New Order For 3. JLL (PO)</h2>

@using (Html.BeginForm("Switch", "Order", FormMethod.Post))
{

    <div align="center">Select A Company @Html.DropDownList("Company", Model.company.CompanyNameList, null, new
                                    {
                                        title = "Pick Batch",
                                        onchange = "submit();"
                                    })</div>
}

@using (Html.BeginForm("MultipleCommand", "Order", FormMethod.Post))
{
    @Html.ValidationSummary(true)

    <table align="center">
        <tr>
            <td width="100">FM</td>
            <td>@Html.DropDownList("FMCode", Model.fm.FMNameList)</td>
            <td>Date</td>
            <td>@Html.DisplayFor(x => x.CreateDate)</td>
        </tr>
        <tr></tr>
        <tr>
            <td>Location</td>
            <td>@Html.TextBox("Location")</td>
            <td>Quotation No.</td>
            <td>@Html.DisplayFor(x => x.NextAvaliableNumber)</td>
        </tr>
        <tr></tr>
        <tr>
            <td></td>
            <td><button type="submit" name="Command" value="Add">Add</button></td>
            <td><button type="submit" name="Command" value="BackToMainMenu">Back To Main Menu</button></td>
        </tr>
    </table>
    if (Model.orderList != null)
    {
        <br align="center"/>
        <table align="center" border="1">
            <thead>
                <tr>
                    <th width="100">FM</th>
                    <th width="150">Date</th>
                    <th width="100">Quotation No.</th>
                    <th>Location</th>
                </tr>
            </thead>
            <tbody>
                @foreach (var item in Model.orderList)
                {
                    <tr>
                        <td align="center">@item.FMCode</td>
                        <td align="center">@item.CreationDate.ToString("yyyy-MMM-dd", CultureInfo.CreateSpecificCulture("en-US"))</td>
                        <td align="center">@item.QuotationNo</td>
                        <td align="center">@item.Location</td>
                    </tr>
                }
            </tbody>
        </table>
        <table align="center">
            <tr>
                <td width="100"></td>
                <td width="150"></td>
                <td width="100">Total Number</td>
                <td align="center">@Html.DisplayFor(model => model.orderList.Count)</td>
            </tr>
        </table>
        <br align="center"/>
        <div align="center">
            <button type="submit" name="Command" value="Confirm">Confirm</button>
            <button type="submit" name="Command" value="Cancel">Cancel</button>
            <button type="submit" name="Command" value="Clear">Clear</button> 
        </div>
    }
}